import QtQuick 1.1
import com.nokia.symbian 1.1

PageStackWindow {
    id: window
    initialPage: loadPage
    showStatusBar: true
    showToolBar: true
    platformSoftwareInputPanelEnabled: true

    Loading {
        id: loadPage
        tools: toolBarLayout

        onCarregado: {
            loadPage.fecharTela();
        }
    }

    Component.onCompleted: {
        var comp = Qt.createComponent("MainPage.qml");
        if (comp.status == Component.Ready)
        {
            var obj = comp.createObject(window);
            obj.tools = toolBarLayout;
            loadPage.fechado.connect(function()
                                     {
                                         window.pageStack.replace(obj);
                                     });            

        }
        else
        {
            console.log("Erro: componente MainPage.qml - " + comp.errorString());
        }
    }

    ToolBarLayout {
        id: toolBarLayout
        ToolButton {
            flat: true
            iconSource: "toolbar-back"
            onClicked: window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()
        }
        ToolButton {
            flat: true
            iconSource: "toolbar-menu"
            onClicked: mnuMais.open();
        }
    }

    Menu {
        id: mnuMais
        MenuLayout {
            MenuItem {
                text: "Ajuda"
                onClicked: {
                    pageStack.push(Qt.resolvedUrl("PageAjuda.qml"))
                }
            }
            MenuItem {
                text: "Sobre"
                onClicked: {
                    pageStack.push(Qt.resolvedUrl("PageSobre.qml"));
                }
            }
        }
    }
}
